package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.UserCoupons;
import com.sc.nft.entity.UserEcologyReforgeUpperLimit;
import com.sc.nft.entity.vo.ecology.AdminUserEcologyCastUpperLimitPageVO;
import com.sc.nft.entity.vo.ecology.UserEcologyCastUpperLimitDetailsVO;
import com.sc.nft.enums.UserCouponsStatusEnum;
import com.sc.nft.enums.UserEcologyCastUpperLimitDetailsTypeEnum;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.UserEcologyCastUpperLimitDetails;
import com.sc.nft.mapper.UserEcologyCastUpperLimitDetailsMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * 生态-铸造上限记录明细表(sc_user_ecology_cast_upper_limit_details)数据DAO
 *
 * @author Sun
 * @since 2024-03-12 20:04:32
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class UserEcologyCastUpperLimitDetailsDao extends ServiceImpl<UserEcologyCastUpperLimitDetailsMapper, UserEcologyCastUpperLimitDetails> {

    public Page<UserEcologyCastUpperLimitDetailsVO> getUserEcologyCastUpperLimitDetails(Long userId, Long collectionId,Integer pageNo, Integer pageSize) {
        return baseMapper.getUserEcologyCastUpperLimitDetails(new Page<>(pageNo, pageSize), userId,collectionId);
    }

    public Page<AdminUserEcologyCastUpperLimitPageVO> getUserEcologyCastUpperLimitPage(Long userId, Long collectionId, Date beginTime, Date endTime, Integer pageNo, Integer pageSize) {
        return baseMapper.getUserEcologyCastUpperLimitPage(new Page<>(pageNo, pageSize), userId, collectionId, beginTime, endTime);
    }

    /**
     * 批量入库
     *
     * @param list
     * @return
     */
    public Integer saveList(List<UserEcologyCastUpperLimitDetails> list){
        return baseMapper.saveList(list);
    }

    public List<UserEcologyCastUpperLimitDetails> getByUserRecordsIds(List<Long> userRecordsIds) {
        LambdaQueryWrapper<UserEcologyCastUpperLimitDetails> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(UserEcologyCastUpperLimitDetails::getUserRecordsId, userRecordsIds);
        wrapper.eq(UserEcologyCastUpperLimitDetails::getType, UserEcologyCastUpperLimitDetailsTypeEnum.SMELTING);
        return baseMapper.selectList(wrapper);
    }
}